home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
AMICUS
/
AMICUS15.ADF
/
C
/
Ask.c
next >
Wrap
C/C++ Source or Header
|
1988-04-20
|
2KB
|
67 lines
/********************************************************
* ASK: For use in a batch file to ask a question for *
* branching purposes. Simple command line parse *
* with a switch case searching for key negatives *
* and exiting with error lever 5 (warning) if *
* found, error level 0 if not found. Negatives *
* include 0,f F,n,N. This is public domain, but *
* inquiries are welcome. See the confess() *
* function below, or reach me thru CIS 71725,745 *
* The Well: RSVP, or GEnie: Jim.Thomas *
********************************************************/
#include <stdio.h>
main (argc,argv) /*ASK: Returns error level upon response*/
int argc;
char *argv[];
{
int failat,i;
char c;
failat = 0;
if (argc == 1)
{
printf("Usage: %s <string>\n\n", argv[0]);
confess();
}
for (i = 1; i < argc; i++)
printf("\033[2m%s\033[0m ",argv[i]);
while ((c = getchar()) == NULL);
switch(c)
{
case '0':
case 'n':
case 'N':
case 'f':
case 'F':
failat = 5;
break;
default:
failat = 0;
break;
}
while ((c = getchar()) != '\n');
exit(failat);
}
confess() /*Are you going to talk? Or do we have to beat it out of you?*/
{
printf(" Support your local Amiga Users Group\n\n");
printf(" This program is provided as public domain for Amiga users.\n");
printf(" Written by Jim Thomas, an AUGgie doggie. For information:\n\n");
printf(" AUGment\n");
printf(" P.O. Box 1863\n");
printf(" Fremont, CA 94538-0186\n\n");
printf(" AUGment BBS: (415) 659-9169\n\n");
printf(" AUGment Hot line: (415) 651-1160\n\n");
exit(0);
}